<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>确认订单</title>  
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/base.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/detail.css" />
</head>
<body> 
<div class="prodetail">
	<div class="address">
        <div class="add" style="background: none">
            <a href="javascript:;">
                <h3><span><?=$member_info['realname']?></span><span><?=$member_info['mobile']?></span></h3>
                <p>收货地址：<?=$comm_info['address']?></p>
                <notempty name="goods_info['storename1']">
                    <b>由<?=$goods_info['storename1']?>代收</b>
                </notempty>
            </a>

        </div>
    </div>

    <div class="prolist">
    	<div class="pro">

            <div class="pic"><img src="<?=$goods_info['h_imgs']?>"/></div>
            <div class="name">
                <h2><b class="<eq name="goods_info.type" value="0">xc<else/>md</eq>"><?=$goods_info['type']==0?'乡村':'门店'?></b><?=$goods_info['title']?></h2>
                <p><b><img src="<?=$store_info['avatar']?>"/></b><i><?=$store_info['nickname']?></i><em><?=$goods_info['storename']?></em></p>
                <h3>
                    <del>原价：￥<?=$goods_info['price']?></del>
                    <em>￥<?=$goods_info['actual_price']?></em>
                    <input type="hidden" id="onePrice" value="<?=$goods_info['actual_price']?>">
                    <if condition="$goods_info['limit_state'] eq 1">
                        <span class="num"><s class="Subtract">-</s><b>1</b><s class="add limitnum1">+</s></span>
                        <else />
                        <span class="num"><s class="Subtract">-</s><b>1</b><s class="add addnum">+</s></span>
                        <input type="hidden" id="maxnum" value="<?=$goods_info['max_num']?>">
                    </if>
                </h3>
            </div>


        </div>
        <div class="note">本产品为自提商品，社区二次分拣，开心享受美味</div>
    </div>

    <div class="word">
    	<h2>拼团须知</h2>
        <div class="inner">
            <!--<p>{$goods_info.server}</p>-->
     <eq name="goods_info.type" value="0">
         <if condition="$goods_info['limit_state'] eq 1">
             <p>1.同一产品每人仅限一份（2斤）；</p>
             <p>2.拼团成功24小时农户发货，拼团失败退还金额；</p>
             <p>3.同一社区拼团，产品送社区生鲜店自提；</p>
             <p>4.社区生鲜店二次分拣，品质把关，无损坏、差货烦恼；</p>
             <p>5.如社区暂无生鲜店对接，社区团友可协商收货地址或推荐认可的社区生鲜店做分拣服务；
             <p>6.如有愿为社区团友做收货分拣服务，请在公众号留言或电话027-87872733；</p>
             <p>7.本次活动限武汉三环内市区。</p>
         <else />
              <p>1.参与拼团，达到拼团人次可成团2</p>
              <p>2.在拼团时间内，已成团也可继续参团</p>
              <p>3.若活动时间截止，还未成团，则拼团失败，退还金额</p>
              <p>4.活动截止后24小时内发货</p>
              <p>5.三天内到货，社区店二次分拣，新鲜保证。你收到取货通知及取货码，凭取货码社区店取货</p>
         </if>
    <else />
            <p>1.参与拼团，达到拼团人次可成团</p>
            <p>2.在拼团时间内，已成团可继续参团</p>
            <p>3.若活动截止时间，还未成团，则拼团失败，退还金额</p>
            <p>4.活动截止后，根据预定数量，次日商家进货</p>
            <p>5.到货后，社区店进行打包，新鲜保证。你会收到取货通知及取货码，凭取货码取货</p>
    </eq>
        </div>
    </div>
    
    <!--默认无此结构-->
    <if condition=" ($copy_info neq 1) AND ($copy_info neq '')">
        <div class="people">
            <if condition="$copy_info['orsuccess'] eq 0">
                <!--已开团-->
				<h2>已订购<span><?=$copy_info['num']?></span>份
                <?php if($goods_info['min_num']-$copy_info['num']>0)echo "，还差<span>".($goods_info['min_num']-$copy_info['num'])."</span>份成团";?>
                </h2>
            <else />
                <!--已成团-->
                <h2>已成团,可继续参与购买</h2>
            </if>
            <!--拼团成员-->
            <div class="list">
                <ul>
                    <volist name="group_member" id="vo">
                        <li>
                            <div class="pic"><img src="{$vo.avatar}"/></div><h3>{$vo.nickname}</h3><b>{$vo.hometown}</b>
                        </li>
                    </volist>
                </ul>
            </div>

        </div>

    </if>
    <!--默认无-->
    <!--已开团状态-->
   	<div class="time" id="time"><i>限时拼团</i><span>距离结束还剩</span>
    	<div class="time-item"><span id="day_show">0</span>天<strong id="hour_show"><s id="h"></s>0</strong>时<strong id="minute_show"><s></s>00</strong>分<strong id="second_show"><s></s>00</strong>秒</div>
	</div>
    <div class="sure">
        <form action="<?=U('MyGrouporder/confirmorder')?>" method="post" id="form">
            <input type="hidden" name="sg_id" value="<?=$goods_info['id']?>">
            <input type="hidden" name="c_id" value="<?=$copy_info['id']?>">
            <input type="hidden" name="num" id="num" value="1">
            <input type="hidden" name="comm_id" value="<?=$comm_info['id']?>">
            <input type="hidden" name="realname" value="<?=$member_info['realname']?>">
            <input type="hidden" name="tel" value="<?=$member_info['mobile']?>">
            <!--批发，暂时注释-->
            <!--<input type="hidden" name="range_id" value="0">-->
            <p>应付金额：<em>￥<span id="total_price"><?=$goods_info['actual_price']?></span></em></p>
            <input type="button" id="form-button" data-status="1" value="提交订单"/>
        </form>

    </div>
</div>
	<!--<script  src="__PUBLIC__/Wx/js/jquery-1.3.1.min.js" type="text/javascript"></script>-->
    <script src="__PUBLIC__/Wx/js/jquery.js" ></script>
    <script src="__PUBLIC__/js/jquery.form.js"></script>
    <script src="__PUBLIC__/js/layer/layer.js"></script>


	<script type="text/javascript">

		(function($){
			$(function(){
				var $Width = $('.people .list ul').width()/5.3;
				var len = $(".people .list ul li").length;
			//	alert(len);
				$('.people .list ul li').css({'width':$Width});
				$('.people .list ul').css({'width':$Width*len});
			})
		})(jQuery)

        // 防止重复提交订单
        $("#form-button").click(function () {
            var state = $(this).attr('data-status');
            if(state=='1'){
                $("#form").submit();
            }else{
                layer.msg('订单已提交，请勿重复点击');
            }
            $(this).attr('data-status','2');
        })

        $(".limitnum1").click(function () {
            layer.msg('本商品限购一份', {icon:2,time:2000});
        })

        //商品数量增加
        $(".addnum").click(function(){
            var num = parseInt($(this).siblings("b").text())+1;
            var maxnum = $("#maxnum").val();
            if(num <= maxnum){
                $(this).siblings("b").text(num);
                $("#num").val(num);
                var one = $("#onePrice").val();
                // 获取应付金额
                var total_price = $("#total_price").text();
                var total=  jisuan(total_price*1 + one*1, 2);
                $("#total_price").text(total);
            }else{
                layer.msg('已达到最大库存');
                return false;
            }

        });//end fun

        //商品数量减少
        $(".Subtract").click(function(){
            var num = parseInt($(this).siblings("b").text())-1;
            if(num>=1){
                $(this).siblings("b").text(num);
                $("#num").val(num);
                // 此时商品的单价
                var one = $("#onePrice").val();
                // 获取应付金额
                var total_price = $("#total_price").text();
                var total=  jisuan(total_price - one, 2);
                $("#total_price").text(total);
            }
        });//end fun

        // 如果是门店拼团
        var u_type={$u_type};
		if(u_type==1||u_type==3){
            //获取区间数量
            var num1 = $(".price-range p:first-child").children("span:eq(0)").text();
            var num2 = $(".price-range p:nth-child(2)").children("span:eq(0)").text();
            var num3 = $(".price-range p:nth-child(3)").children("span:eq(0)").text();

            $(".addnum1").click(function(){
                var num = parseInt($(this).siblings("b").text())+1;
                var maxnum = $("#maxnum").val();
                if(num <= maxnum){
                    $(this).siblings("b").text(num);    //商品数量变动
                    $("#num").val(num);
                    var one = checknum(num);    //判断区间，获取商品单价
                    var total=  jisuan(one*num, 2);
                    $("#total_price").text(total);
                }else{
                    layer.msg('已达到最大库存');
                    return false;
                }

            });//end fun

            $(".Subtract1").click(function(){
                var num = parseInt($(this).siblings("b").text())-1;
                if(num>=1){
                    $(this).siblings("b").text(num);
                    $("#num").val(num);
                    // 此时商品的单价
                    var one = checknum(num);
                    var total=  jisuan(one*num, 2);
                    $("#total_price").text(total);
                }
            });//end fun

            // 检查商品数量区间
            function checknum(num) {
                // 如果在第一个区间
                if(num>=num1){
                    // 获取价格
                    var price = $(".price-range p:first-child").children("span:eq(1)").text();
                    var range_id = $(".price-range p:first-child").attr('data-range');

                    // 如果在第二个区间
                    if(num>=num2){
                        // 获取价格
                        var price = $(".price-range p:nth-child(2)").children("span:eq(1)").text();
                        var range_id = $(".price-range p:nth-child(2)").attr('data-range');
                        // 如果在第三个区间
                        if(num>=num3){
                            // 获取价格
                            var price = $(".price-range p:nth-child(3)").children("span:eq(1)").text();
                            var range_id = $(".price-range p:nth-child(3)").attr('data-range');
                        }
                    }
                }
                $("input[name='range_id']").val(range_id);
                return price;
            }

        }//end if

        //商品价格计算精度问题
        function  jisuan(f, digit) {
            var m = Math.pow(10, digit);
            return Math.round(f * m, 10) / m;
        }

    </script>

    <script type="text/javascript">
        var intDiff = parseInt(<?php echo $goods_info['endtime']-time();?>);//倒计时总秒数量

        function timer(intDiff){
            window.setInterval(function(){
            var day=0,
                hour=00,
                minute=0,
                second=0;//时间默认值
            if(intDiff > 0){
                day = Math.floor(intDiff / (60 * 60 * 24));
                hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
                minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
                second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
            }
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;
            $('#day_show').html(day+""); 
            $('#hour_show').html('<s id="h"></s>'+hour+'');
            $('#minute_show').html('<s></s>'+minute+'');
            $('#second_show').html('<s></s>'+second+'');
            intDiff--;
            }, 1000);
        }
        $(function(){
            timer(intDiff);
        });
    </script>
</body>
</html>